{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e057f306",
   "metadata": {},
   "source": [
    "# Demo: Azure Table Storage as a ChatStore\n",
    "\n",
    "This guide shows you how to use our `AzureChatStore` abstraction which automatically persists chat histories to Azure Table Storage or CosmosDB.\n",
    "\n",
    "<a href=\"https://colab.research.google.com/drive/1b_0JuVwWSXiLZZjeBAPr-u5_Y9b34Zcp?usp=sharing\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c0bcc1a5",
   "metadata": {},
   "source": [
    "If you're opening this Notebook on colab, you will probably need to install LlamaIndex 🦙."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9a95d78b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: llama-index-storage-chat-store-azure in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (0.1.3)\n",
      "Requirement already satisfied: azure-data-tables<13.0.0,>=12.5.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-storage-chat-store-azure) (12.5.0)\n",
      "Requirement already satisfied: llama-index-core<0.11.0,>=0.10.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-storage-chat-store-azure) (0.10.36)\n",
      "Requirement already satisfied: azure-core<2.0.0,>=1.29.4 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from azure-data-tables<13.0.0,>=12.5.0->llama-index-storage-chat-store-azure) (1.30.1)\n",
      "Requirement already satisfied: yarl<2.0,>=1.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from azure-data-tables<13.0.0,>=12.5.0->llama-index-storage-chat-store-azure) (1.9.4)\n",
      "Requirement already satisfied: isodate<1.0.0,>=0.6.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from azure-data-tables<13.0.0,>=12.5.0->llama-index-storage-chat-store-azure) (0.6.1)\n",
      "Requirement already satisfied: typing-extensions>=4.3.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from azure-data-tables<13.0.0,>=12.5.0->llama-index-storage-chat-store-azure) (4.11.0)\n",
      "Requirement already satisfied: PyYAML>=6.0.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (6.0.1)\n",
      "Requirement already satisfied: SQLAlchemy>=1.4.49 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from SQLAlchemy[asyncio]>=1.4.49->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (2.0.30)\n",
      "Requirement already satisfied: aiohttp<4.0.0,>=3.8.6 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (3.9.5)\n",
      "Requirement already satisfied: dataclasses-json in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (0.6.6)\n",
      "Requirement already satisfied: deprecated>=1.2.9.3 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (1.2.14)\n",
      "Requirement already satisfied: dirtyjson<2.0.0,>=1.0.8 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (1.0.8)\n",
      "Requirement already satisfied: fsspec>=2023.5.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (2024.3.1)\n",
      "Requirement already satisfied: httpx in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (0.27.0)\n",
      "Requirement already satisfied: llamaindex-py-client<0.2.0,>=0.1.18 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (0.1.19)\n",
      "Requirement already satisfied: nest-asyncio<2.0.0,>=1.5.8 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (1.6.0)\n",
      "Requirement already satisfied: networkx>=3.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (3.1)\n",
      "Requirement already satisfied: nltk<4.0.0,>=3.8.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (3.8.1)\n",
      "Requirement already satisfied: numpy in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (1.24.4)\n",
      "Requirement already satisfied: openai>=1.1.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (1.28.0)\n",
      "Requirement already satisfied: pandas in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (2.0.3)\n",
      "Requirement already satisfied: pillow>=9.0.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (10.3.0)\n",
      "Requirement already satisfied: requests>=2.31.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (2.31.0)\n",
      "Requirement already satisfied: tenacity<9.0.0,>=8.2.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (8.3.0)\n",
      "Requirement already satisfied: tiktoken>=0.3.3 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (0.6.0)\n",
      "Requirement already satisfied: tqdm<5.0.0,>=4.66.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (4.66.4)\n",
      "Requirement already satisfied: typing-inspect>=0.8.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (0.9.0)\n",
      "Requirement already satisfied: wrapt in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (1.16.0)\n",
      "Requirement already satisfied: aiosignal>=1.1.2 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (1.3.1)\n",
      "Requirement already satisfied: attrs>=17.3.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (23.2.0)\n",
      "Requirement already satisfied: frozenlist>=1.1.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (1.4.1)\n",
      "Requirement already satisfied: multidict<7.0,>=4.5 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (6.0.5)\n",
      "Requirement already satisfied: six>=1.11.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from azure-core<2.0.0,>=1.29.4->azure-data-tables<13.0.0,>=12.5.0->llama-index-storage-chat-store-azure) (1.16.0)\n",
      "Requirement already satisfied: pydantic>=1.10 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llamaindex-py-client<0.2.0,>=0.1.18->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (2.7.1)\n",
      "Requirement already satisfied: anyio in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from httpx->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (4.3.0)\n",
      "Requirement already satisfied: certifi in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from httpx->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (2024.2.2)\n",
      "Requirement already satisfied: httpcore==1.* in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from httpx->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (1.0.5)\n",
      "Requirement already satisfied: idna in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from httpx->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (3.7)\n",
      "Requirement already satisfied: sniffio in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from httpx->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (1.3.1)\n",
      "Requirement already satisfied: h11<0.15,>=0.13 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from httpcore==1.*->httpx->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (0.14.0)\n",
      "Requirement already satisfied: click in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (8.1.7)\n",
      "Requirement already satisfied: joblib in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (1.4.2)\n",
      "Requirement already satisfied: regex>=2021.8.3 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (2024.5.10)\n",
      "Requirement already satisfied: distro<2,>=1.7.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from openai>=1.1.0->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (1.9.0)\n",
      "Requirement already satisfied: charset-normalizer<4,>=2 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from requests>=2.31.0->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (3.3.2)\n",
      "Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from requests>=2.31.0->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (2.2.1)\n",
      "Requirement already satisfied: greenlet!=0.4.17 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from SQLAlchemy[asyncio]>=1.4.49->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (3.0.3)\n",
      "Requirement already satisfied: mypy-extensions>=0.3.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from typing-inspect>=0.8.0->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (1.0.0)\n",
      "Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from dataclasses-json->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (3.21.2)\n",
      "Requirement already satisfied: python-dateutil>=2.8.2 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from pandas->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (2.9.0.post0)\n",
      "Requirement already satisfied: pytz>=2020.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from pandas->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (2024.1)\n",
      "Requirement already satisfied: tzdata>=2022.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from pandas->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (2024.1)\n",
      "Requirement already satisfied: packaging>=17.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from marshmallow<4.0.0,>=3.18.0->dataclasses-json->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (24.0)\n",
      "Requirement already satisfied: annotated-types>=0.4.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from pydantic>=1.10->llamaindex-py-client<0.2.0,>=0.1.18->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (0.6.0)\n",
      "Requirement already satisfied: pydantic-core==2.18.2 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from pydantic>=1.10->llamaindex-py-client<0.2.0,>=0.1.18->llama-index-core<0.11.0,>=0.10.1->llama-index-storage-chat-store-azure) (2.18.2)\n",
      "Note: you may need to restart the kernel to use updated packages.\n",
      "Requirement already satisfied: llama-index-llms-azure-openai in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (0.1.5)\n",
      "Requirement already satisfied: azure-identity<2.0.0,>=1.15.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-llms-azure-openai) (1.15.0)\n",
      "Requirement already satisfied: httpx in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-llms-azure-openai) (0.27.0)\n",
      "Requirement already satisfied: llama-index-core<0.11.0,>=0.10.11.post1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-llms-azure-openai) (0.10.36)\n",
      "Requirement already satisfied: llama-index-llms-openai<0.2.0,>=0.1.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-llms-azure-openai) (0.1.14)\n",
      "Requirement already satisfied: azure-core<2.0.0,>=1.23.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from azure-identity<2.0.0,>=1.15.0->llama-index-llms-azure-openai) (1.30.1)\n",
      "Requirement already satisfied: cryptography>=2.5 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from azure-identity<2.0.0,>=1.15.0->llama-index-llms-azure-openai) (42.0.7)\n",
      "Requirement already satisfied: msal<2.0.0,>=1.24.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from azure-identity<2.0.0,>=1.15.0->llama-index-llms-azure-openai) (1.28.0)\n",
      "Requirement already satisfied: msal-extensions<2.0.0,>=0.3.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from azure-identity<2.0.0,>=1.15.0->llama-index-llms-azure-openai) (1.1.0)\n",
      "Requirement already satisfied: PyYAML>=6.0.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (6.0.1)\n",
      "Requirement already satisfied: SQLAlchemy>=1.4.49 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from SQLAlchemy[asyncio]>=1.4.49->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (2.0.30)\n",
      "Requirement already satisfied: aiohttp<4.0.0,>=3.8.6 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (3.9.5)\n",
      "Requirement already satisfied: dataclasses-json in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (0.6.6)\n",
      "Requirement already satisfied: deprecated>=1.2.9.3 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (1.2.14)\n",
      "Requirement already satisfied: dirtyjson<2.0.0,>=1.0.8 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (1.0.8)\n",
      "Requirement already satisfied: fsspec>=2023.5.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (2024.3.1)\n",
      "Requirement already satisfied: llamaindex-py-client<0.2.0,>=0.1.18 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (0.1.19)\n",
      "Requirement already satisfied: nest-asyncio<2.0.0,>=1.5.8 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (1.6.0)\n",
      "Requirement already satisfied: networkx>=3.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (3.1)\n",
      "Requirement already satisfied: nltk<4.0.0,>=3.8.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (3.8.1)\n",
      "Requirement already satisfied: numpy in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (1.24.4)\n",
      "Requirement already satisfied: openai>=1.1.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (1.28.0)\n",
      "Requirement already satisfied: pandas in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (2.0.3)\n",
      "Requirement already satisfied: pillow>=9.0.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (10.3.0)\n",
      "Requirement already satisfied: requests>=2.31.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (2.31.0)\n",
      "Requirement already satisfied: tenacity<9.0.0,>=8.2.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (8.3.0)\n",
      "Requirement already satisfied: tiktoken>=0.3.3 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (0.6.0)\n",
      "Requirement already satisfied: tqdm<5.0.0,>=4.66.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (4.66.4)\n",
      "Requirement already satisfied: typing-extensions>=4.5.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (4.11.0)\n",
      "Requirement already satisfied: typing-inspect>=0.8.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (0.9.0)\n",
      "Requirement already satisfied: wrapt in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (1.16.0)\n",
      "Requirement already satisfied: anyio in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from httpx->llama-index-llms-azure-openai) (4.3.0)\n",
      "Requirement already satisfied: certifi in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from httpx->llama-index-llms-azure-openai) (2024.2.2)\n",
      "Requirement already satisfied: httpcore==1.* in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from httpx->llama-index-llms-azure-openai) (1.0.5)\n",
      "Requirement already satisfied: idna in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from httpx->llama-index-llms-azure-openai) (3.7)\n",
      "Requirement already satisfied: sniffio in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from httpx->llama-index-llms-azure-openai) (1.3.1)\n",
      "Requirement already satisfied: h11<0.15,>=0.13 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from httpcore==1.*->httpx->llama-index-llms-azure-openai) (0.14.0)\n",
      "Requirement already satisfied: aiosignal>=1.1.2 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (1.3.1)\n",
      "Requirement already satisfied: attrs>=17.3.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (23.2.0)\n",
      "Requirement already satisfied: frozenlist>=1.1.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (1.4.1)\n",
      "Requirement already satisfied: multidict<7.0,>=4.5 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (6.0.5)\n",
      "Requirement already satisfied: yarl<2.0,>=1.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (1.9.4)\n",
      "Requirement already satisfied: six>=1.11.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from azure-core<2.0.0,>=1.23.0->azure-identity<2.0.0,>=1.15.0->llama-index-llms-azure-openai) (1.16.0)\n",
      "Requirement already satisfied: cffi>=1.12 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from cryptography>=2.5->azure-identity<2.0.0,>=1.15.0->llama-index-llms-azure-openai) (1.16.0)\n",
      "Requirement already satisfied: pydantic>=1.10 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llamaindex-py-client<0.2.0,>=0.1.18->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (2.7.1)\n",
      "Requirement already satisfied: PyJWT<3,>=1.0.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from PyJWT[crypto]<3,>=1.0.0->msal<2.0.0,>=1.24.0->azure-identity<2.0.0,>=1.15.0->llama-index-llms-azure-openai) (2.8.0)\n",
      "Requirement already satisfied: packaging in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from msal-extensions<2.0.0,>=0.3.0->azure-identity<2.0.0,>=1.15.0->llama-index-llms-azure-openai) (24.0)\n",
      "Requirement already satisfied: portalocker<3,>=1.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from msal-extensions<2.0.0,>=0.3.0->azure-identity<2.0.0,>=1.15.0->llama-index-llms-azure-openai) (2.8.2)\n",
      "Requirement already satisfied: click in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (8.1.7)\n",
      "Requirement already satisfied: joblib in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (1.4.2)\n",
      "Requirement already satisfied: regex>=2021.8.3 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (2024.5.10)\n",
      "Requirement already satisfied: distro<2,>=1.7.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from openai>=1.1.0->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (1.9.0)\n",
      "Requirement already satisfied: charset-normalizer<4,>=2 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from requests>=2.31.0->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (3.3.2)\n",
      "Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from requests>=2.31.0->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (2.2.1)\n",
      "Requirement already satisfied: greenlet!=0.4.17 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from SQLAlchemy[asyncio]>=1.4.49->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (3.0.3)\n",
      "Requirement already satisfied: mypy-extensions>=0.3.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from typing-inspect>=0.8.0->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (1.0.0)\n",
      "Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from dataclasses-json->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (3.21.2)\n",
      "Requirement already satisfied: python-dateutil>=2.8.2 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from pandas->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (2.9.0.post0)\n",
      "Requirement already satisfied: pytz>=2020.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from pandas->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (2024.1)\n",
      "Requirement already satisfied: tzdata>=2022.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from pandas->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (2024.1)\n",
      "Requirement already satisfied: pycparser in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from cffi>=1.12->cryptography>=2.5->azure-identity<2.0.0,>=1.15.0->llama-index-llms-azure-openai) (2.22)\n",
      "Requirement already satisfied: annotated-types>=0.4.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from pydantic>=1.10->llamaindex-py-client<0.2.0,>=0.1.18->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (0.6.0)\n",
      "Requirement already satisfied: pydantic-core==2.18.2 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from pydantic>=1.10->llamaindex-py-client<0.2.0,>=0.1.18->llama-index-core<0.11.0,>=0.10.11.post1->llama-index-llms-azure-openai) (2.18.2)\n",
      "Note: you may need to restart the kernel to use updated packages.\n",
      "Requirement already satisfied: llama-index in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (0.10.27)\n",
      "Requirement already satisfied: llama-index-agent-openai<0.3.0,>=0.1.4 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index) (0.2.2)\n",
      "Requirement already satisfied: llama-index-cli<0.2.0,>=0.1.2 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index) (0.1.11)\n",
      "Requirement already satisfied: llama-index-core<0.11.0,>=0.10.27 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index) (0.10.36)\n",
      "Requirement already satisfied: llama-index-embeddings-openai<0.2.0,>=0.1.5 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index) (0.1.7)\n",
      "Requirement already satisfied: llama-index-indices-managed-llama-cloud<0.2.0,>=0.1.2 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index) (0.1.5)\n",
      "Requirement already satisfied: llama-index-legacy<0.10.0,>=0.9.48 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index) (0.9.48)\n",
      "Requirement already satisfied: llama-index-llms-openai<0.2.0,>=0.1.13 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index) (0.1.14)\n",
      "Requirement already satisfied: llama-index-multi-modal-llms-openai<0.2.0,>=0.1.3 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index) (0.1.4)\n",
      "Requirement already satisfied: llama-index-program-openai<0.2.0,>=0.1.3 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index) (0.1.5)\n",
      "Requirement already satisfied: llama-index-question-gen-openai<0.2.0,>=0.1.2 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index) (0.1.3)\n",
      "Requirement already satisfied: llama-index-readers-file<0.2.0,>=0.1.4 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index) (0.1.13)\n",
      "Requirement already satisfied: llama-index-readers-llama-parse<0.2.0,>=0.1.2 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index) (0.1.4)\n",
      "Requirement already satisfied: openai>=1.14.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-agent-openai<0.3.0,>=0.1.4->llama-index) (1.28.0)\n",
      "Requirement already satisfied: PyYAML>=6.0.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (6.0.1)\n",
      "Requirement already satisfied: SQLAlchemy>=1.4.49 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from SQLAlchemy[asyncio]>=1.4.49->llama-index-core<0.11.0,>=0.10.27->llama-index) (2.0.30)\n",
      "Requirement already satisfied: aiohttp<4.0.0,>=3.8.6 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (3.9.5)\n",
      "Requirement already satisfied: dataclasses-json in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (0.6.6)\n",
      "Requirement already satisfied: deprecated>=1.2.9.3 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (1.2.14)\n",
      "Requirement already satisfied: dirtyjson<2.0.0,>=1.0.8 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (1.0.8)\n",
      "Requirement already satisfied: fsspec>=2023.5.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (2024.3.1)\n",
      "Requirement already satisfied: httpx in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (0.27.0)\n",
      "Requirement already satisfied: llamaindex-py-client<0.2.0,>=0.1.18 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (0.1.19)\n",
      "Requirement already satisfied: nest-asyncio<2.0.0,>=1.5.8 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (1.6.0)\n",
      "Requirement already satisfied: networkx>=3.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (3.1)\n",
      "Requirement already satisfied: nltk<4.0.0,>=3.8.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (3.8.1)\n",
      "Requirement already satisfied: numpy in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (1.24.4)\n",
      "Requirement already satisfied: pandas in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (2.0.3)\n",
      "Requirement already satisfied: pillow>=9.0.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (10.3.0)\n",
      "Requirement already satisfied: requests>=2.31.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (2.31.0)\n",
      "Requirement already satisfied: tenacity<9.0.0,>=8.2.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (8.3.0)\n",
      "Requirement already satisfied: tiktoken>=0.3.3 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (0.6.0)\n",
      "Requirement already satisfied: tqdm<5.0.0,>=4.66.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (4.66.4)\n",
      "Requirement already satisfied: typing-extensions>=4.5.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (4.11.0)\n",
      "Requirement already satisfied: typing-inspect>=0.8.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (0.9.0)\n",
      "Requirement already satisfied: wrapt in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-core<0.11.0,>=0.10.27->llama-index) (1.16.0)\n",
      "Requirement already satisfied: beautifulsoup4<5.0.0,>=4.12.3 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-readers-file<0.2.0,>=0.1.4->llama-index) (4.12.3)\n",
      "Requirement already satisfied: pymupdf<2.0.0,>=1.23.21 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-readers-file<0.2.0,>=0.1.4->llama-index) (1.24.1)\n",
      "Requirement already satisfied: pypdf<5.0.0,>=4.0.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-readers-file<0.2.0,>=0.1.4->llama-index) (4.1.0)\n",
      "Requirement already satisfied: striprtf<0.0.27,>=0.0.26 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-readers-file<0.2.0,>=0.1.4->llama-index) (0.0.26)\n",
      "Requirement already satisfied: llama-parse<0.5.0,>=0.4.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llama-index-readers-llama-parse<0.2.0,>=0.1.2->llama-index) (0.4.0)\n",
      "Requirement already satisfied: aiosignal>=1.1.2 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.27->llama-index) (1.3.1)\n",
      "Requirement already satisfied: attrs>=17.3.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.27->llama-index) (23.2.0)\n",
      "Requirement already satisfied: frozenlist>=1.1.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.27->llama-index) (1.4.1)\n",
      "Requirement already satisfied: multidict<7.0,>=4.5 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.27->llama-index) (6.0.5)\n",
      "Requirement already satisfied: yarl<2.0,>=1.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.27->llama-index) (1.9.4)\n",
      "Requirement already satisfied: soupsieve>1.2 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from beautifulsoup4<5.0.0,>=4.12.3->llama-index-readers-file<0.2.0,>=0.1.4->llama-index) (2.5)\n",
      "Requirement already satisfied: pydantic>=1.10 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from llamaindex-py-client<0.2.0,>=0.1.18->llama-index-core<0.11.0,>=0.10.27->llama-index) (2.7.1)\n",
      "Requirement already satisfied: anyio in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from httpx->llama-index-core<0.11.0,>=0.10.27->llama-index) (4.3.0)\n",
      "Requirement already satisfied: certifi in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from httpx->llama-index-core<0.11.0,>=0.10.27->llama-index) (2024.2.2)\n",
      "Requirement already satisfied: httpcore==1.* in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from httpx->llama-index-core<0.11.0,>=0.10.27->llama-index) (1.0.5)\n",
      "Requirement already satisfied: idna in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from httpx->llama-index-core<0.11.0,>=0.10.27->llama-index) (3.7)\n",
      "Requirement already satisfied: sniffio in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from httpx->llama-index-core<0.11.0,>=0.10.27->llama-index) (1.3.1)\n",
      "Requirement already satisfied: h11<0.15,>=0.13 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from httpcore==1.*->httpx->llama-index-core<0.11.0,>=0.10.27->llama-index) (0.14.0)\n",
      "Requirement already satisfied: click in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core<0.11.0,>=0.10.27->llama-index) (8.1.7)\n",
      "Requirement already satisfied: joblib in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core<0.11.0,>=0.10.27->llama-index) (1.4.2)\n",
      "Requirement already satisfied: regex>=2021.8.3 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core<0.11.0,>=0.10.27->llama-index) (2024.5.10)\n",
      "Requirement already satisfied: distro<2,>=1.7.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from openai>=1.14.0->llama-index-agent-openai<0.3.0,>=0.1.4->llama-index) (1.9.0)\n",
      "Requirement already satisfied: PyMuPDFb==1.24.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from pymupdf<2.0.0,>=1.23.21->llama-index-readers-file<0.2.0,>=0.1.4->llama-index) (1.24.1)\n",
      "Requirement already satisfied: charset-normalizer<4,>=2 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from requests>=2.31.0->llama-index-core<0.11.0,>=0.10.27->llama-index) (3.3.2)\n",
      "Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from requests>=2.31.0->llama-index-core<0.11.0,>=0.10.27->llama-index) (2.2.1)\n",
      "Requirement already satisfied: greenlet!=0.4.17 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from SQLAlchemy[asyncio]>=1.4.49->llama-index-core<0.11.0,>=0.10.27->llama-index) (3.0.3)\n",
      "Requirement already satisfied: mypy-extensions>=0.3.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from typing-inspect>=0.8.0->llama-index-core<0.11.0,>=0.10.27->llama-index) (1.0.0)\n",
      "Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from dataclasses-json->llama-index-core<0.11.0,>=0.10.27->llama-index) (3.21.2)\n",
      "Requirement already satisfied: python-dateutil>=2.8.2 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from pandas->llama-index-core<0.11.0,>=0.10.27->llama-index) (2.9.0.post0)\n",
      "Requirement already satisfied: pytz>=2020.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from pandas->llama-index-core<0.11.0,>=0.10.27->llama-index) (2024.1)\n",
      "Requirement already satisfied: tzdata>=2022.1 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from pandas->llama-index-core<0.11.0,>=0.10.27->llama-index) (2024.1)\n",
      "Requirement already satisfied: packaging>=17.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from marshmallow<4.0.0,>=3.18.0->dataclasses-json->llama-index-core<0.11.0,>=0.10.27->llama-index) (24.0)\n",
      "Requirement already satisfied: annotated-types>=0.4.0 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from pydantic>=1.10->llamaindex-py-client<0.2.0,>=0.1.18->llama-index-core<0.11.0,>=0.10.27->llama-index) (0.6.0)\n",
      "Requirement already satisfied: pydantic-core==2.18.2 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from pydantic>=1.10->llamaindex-py-client<0.2.0,>=0.1.18->llama-index-core<0.11.0,>=0.10.27->llama-index) (2.18.2)\n",
      "Requirement already satisfied: six>=1.5 in /Users/falven/.pyenv/versions/3.11.8/envs/llama_index/lib/python3.11/site-packages (from python-dateutil>=2.8.2->pandas->llama-index-core<0.11.0,>=0.10.27->llama-index) (1.16.0)\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "%pip install llama-index\n",
    "%pip install llama-index-llms-azure-openai\n",
    "%pip install llama-index-storage-chat-store-azure"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a54d1c43-4b7f-4917-939f-a964f6f3dafc",
   "metadata": {},
   "outputs": [],
   "source": [
    "import nest_asyncio\n",
    "\n",
    "nest_asyncio.apply()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fa67fa07-1395-4aab-a356-72bdb302f6b2",
   "metadata": {},
   "outputs": [],
   "source": [
    "import logging\n",
    "import sys\n",
    "\n",
    "logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n",
    "logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))\n",
    "logging.getLogger(\"azure.core.pipeline.policies.http_logging_policy\").setLevel(\n",
    "    logging.WARNING\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1d12d766-3ca8-4012-9da2-248be80bb6ab",
   "metadata": {},
   "outputs": [],
   "source": [
    "from llama_index.llms.azure_openai import AzureOpenAI\n",
    "from llama_index.core.response.notebook_utils import display_response\n",
    "from llama_index.core import Settings"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b6893fbc",
   "metadata": {},
   "source": [
    "# Define our models\n",
    "\n",
    "In staying with the Azure theme, let's define our Azure OpenAI embedding and LLM models."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "26a01944",
   "metadata": {},
   "outputs": [],
   "source": [
    "Settings.llm = AzureOpenAI(\n",
    "    model=\"gpt-4\",\n",
    "    deployment_name=\"gpt-4\",\n",
    "    api_key=\"\",\n",
    "    azure_endpoint=\"\",\n",
    "    api_version=\"2024-03-01-preview\",\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "332c79f6",
   "metadata": {},
   "source": [
    "We now define an `AzureChatStore`, memory and `SimpleChatEngine` to converse and store history in Azure Table Storage."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1593ca1d",
   "metadata": {},
   "outputs": [],
   "source": [
    "from llama_index.core.chat_engine import SimpleChatEngine\n",
    "from llama_index.core.memory import ChatMemoryBuffer\n",
    "from llama_index.storage.chat_store.azure import AzureChatStore\n",
    "\n",
    "chat_store = AzureChatStore.from_account_and_key(\n",
    "    account_name=\"\",\n",
    "    account_key=\"\",\n",
    "    chat_table_name=\"FranChat\",\n",
    "    metadata_table_name=\"FranChatMeta\",\n",
    "    metadata_partition_key=\"conversation1\",\n",
    ")\n",
    "\n",
    "memory = ChatMemoryBuffer.from_defaults(\n",
    "    token_limit=3000,\n",
    "    chat_store=chat_store,\n",
    "    chat_store_key=\"conversation1\",\n",
    ")\n",
    "\n",
    "chat_engine = SimpleChatEngine(\n",
    "    memory=memory, llm=Settings.llm, prefix_messages=[]\n",
    ")"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "d3bf6aaf-3375-4212-8323-777969a918f7",
   "metadata": {},
   "source": [
    "#### Test out a ChatEngine with memory backed by Azure Table Storage"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "544c0565-72a0-434b-98e5-83138ebdaa2b",
   "metadata": {},
   "outputs": [],
   "source": [
    "response = chat_engine.chat(\"Hello, my name is Fran.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "39d250be",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "**`Final Response:`** Hello Fran! How can I assist you today?"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display_response(response)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5c838580",
   "metadata": {},
   "outputs": [],
   "source": [
    "response = chat_engine.chat(\"What's my name again?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "91db5b71",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "**`Final Response:`** Your name is Fran. How can I help you further?"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display_response(response)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "94f3594c",
   "metadata": {},
   "source": [
    "#### Start a new conversation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ae01fa9a",
   "metadata": {},
   "outputs": [],
   "source": [
    "chat_store.metadata_partition_key = \"conversation2\"\n",
    "\n",
    "memory = ChatMemoryBuffer.from_defaults(\n",
    "    token_limit=3000,\n",
    "    chat_store=chat_store,\n",
    "    chat_store_key=\"conversation2\",\n",
    ")\n",
    "\n",
    "chat_engine = SimpleChatEngine(\n",
    "    memory=memory, llm=Settings.llm, prefix_messages=[]\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5d8ddc8c",
   "metadata": {},
   "outputs": [],
   "source": [
    "response = chat_engine.chat(\"What's in a name?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fb28b70e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "**`Final Response:`** \"What's in a name?\" is a famous quote from William Shakespeare's play \"Romeo and Juliet.\" It is spoken by Juliet in Act 2, Scene 2, during the balcony scene. The full quote is:\n",
       "\n",
       "\"What's in a name? That which we call a rose\n",
       "By any other name would smell as sweet.\"\n",
       "\n",
       "In this context, Juliet is musing on the nature of names and identity, specifically referring to Romeo's last name, Montague. The Montagues and the Capulets, Juliet's family, are sworn enemies. Juliet is lamenting the fact that Romeo's name is the only thing that is keeping them apart, implying that the essence or nature of a person is not tied to their name. Essentially, she's arguing that if Romeo had any other name, he would still be the person she loves. The quote speaks to the idea that names themselves do not hold value or meaning beyond the significance that society or individuals ascribe to them."
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display_response(response)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
